package com.lframework.xingyun.basedata.mappers;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import com.lframework.starter.web.core.annotations.sort.Sort;
import com.lframework.starter.web.core.annotations.sort.Sorts;
import com.lframework.starter.web.core.mapper.BaseMapper;
import com.lframework.xingyun.basedata.entity.MemberAccountLog;
import com.lframework.xingyun.basedata.vo.member.QueryMemberAccountLogVo;

/**
 * <p>
 * 会员积分账户变动记录 Mapper 接口
 * </p>
 *
 * @author mos
 */
public interface MemberAccountLogMapper extends BaseMapper<MemberAccountLog> {
    /**
     * 查询会员积分账户变动记录
     * @param pageIndex 页码
     * @param pageSize  每页条数
     * @param vo 查询参数
     * @return 会员积分账户变动记录列表
     */
    @Sorts({
         @Sort(value = "createTime")
    })
    default IPage<MemberAccountLog> query(Integer pageIndex, Integer pageSize, QueryMemberAccountLogVo vo) {
        return defaultJoinWrapper()
                .eq(MemberAccountLog::getMemberId, vo.getMemberId())
                .in(CollUtil.isNotEmpty(vo.getChangeType()), MemberAccountLog::getChangeType, vo.getChangeType())
                .orderByDesc(MemberAccountLog::getId)
                .page(PageDTO.of(pageIndex, pageSize));
    }
}

